﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Collections.Generic;

namespace Lawyer.Web
{
    public partial class dashboard : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            BindPostList();
            BindTodoList();
            //最近完成的
            BindLatestList();
            //
            BindMyTodo();
        }
        private void BindBoxData()
        {
 
        }
        private void BindPostList()
        {
            Lawyer.BLL.PostInfo bll = new Lawyer.BLL.PostInfo();
            List<Lawyer.Model.PostInfo> list = bll.GetModelList(" Status=0 ");
            if (list.Count > 5)
            {
                list = list.Take(5).ToList();
            }
            else {
                
            }
            rptPostList.DataSource = list;
            rptPostList.DataBind();
        }

        private void BindTodoList()
        {
            Lawyer.BLL.ActivityInfo bll = new Lawyer.BLL.ActivityInfo();
            List<Lawyer.Model.ActivityInfo> list = bll.GetModelList(" StartDate >= '" + DateTime.Now.ToString() + "'");
            rptTodoList.DataSource = list;
            rptTodoList.DataBind();

            //
            rptBoxTodoList.DataSource = list;
            rptBoxTodoList.DataBind();
        }
        private void BindLatestList()
        {
            Lawyer.BLL.ActivityInfo bll = new Lawyer.BLL.ActivityInfo();
            List<Lawyer.Model.ActivityInfo> list = bll.GetModelList(" Status=3 ");
            rptLatestList.DataSource = list;
            rptLatestList.DataBind();
        }
        /// <summary>
        /// 绑定过期act处理、卷宗状态修改提醒
        /// </summary>
        private void BindMyTodo()
        {
 //过期act处理
            List<Lawyer.Model.IndexTodoInfo> list = new List<Lawyer.Model.IndexTodoInfo>();
            //Lawyer.BLL.ActivityInfo activitybll = new Lawyer.BLL.ActivityInfo();
            //List<Lawyer.Model.ActivityInfo> activitylist = activitybll.GetModelList("Status=2 AND EndDate<='" + DateTime.Now.ToString() + "'");
            //foreach (var item in activitylist)
            //{
            //    Lawyer.Model.IndexTodoInfo model = new Lawyer.Model.IndexTodoInfo();
            //    model.CreatedDate = item.CreatedDate.Value;
            //    model.Title = item.Title;
            //    model.Type = 10;
            //    list.Add(model);
            //}
            Lawyer.BLL.ArchiveInfo archivebll = new Lawyer.BLL.ArchiveInfo();
            List<Lawyer.Model.ArchiveInfo> archivelist = archivebll.GetModelList(" Status=1 ");
            foreach (var item in archivelist)
            {
                Lawyer.Model.IndexTodoInfo model = new Lawyer.Model.IndexTodoInfo();
                model.CreatedDate = item.CreatedDate.Value;
                model.Title = item.Title;
                model.Type = 20;
                list.Add(model);
            }
            rptMyTodoList.DataSource = list.OrderByDescending(x => x.CreatedDate);
            rptMyTodoList.DataBind();



            rptBoxAlertList.DataSource = list;
            rptBoxAlertList.DataBind();
        }
    }
}
